package com.base.method;

/**
 * 不定长参数
 */
public class Demo03 {
    public static void main(String[] args) {
     printMax(1,4,6,8,23.1,7);
     sum(1,2,6,7,99,31);

    }


    public static void printMax(double ...numbers){
        if (numbers.length == 0) {
            System.out.println("数组为空。。");
            return;
        }

        double result = numbers[0];

        //排序
        for (int i = 1; i < numbers.length; i++) {
            if (numbers[i] > result){
                result = numbers[i];
            }
        }
        System.out.println("最大的值是："+result);

        }


    public static void sum(double a,double b, double ...arr){
        double sum = a+b;
        for (double v : arr) {
            sum +=v;
        }

        System.out.println("计算的和是："+sum);

    }



        }






